<?php

declare(strict_types=1);

namespace App\Model;

use Hyperf\DbConnection\Model\Model;

/**
 *  声优主播申请
 */
class HostApplyLog extends Model
{
    protected $table = 'host_apply_log';

    //待审核
    const STATUS_ING = 0;
    //审核通过
    const STATUS_OK = 1;
    //审核不通过
    const STATUS_FAIL = 2;

    /**
     * 添加记录
     */
    static function addRecord($userId = 0, $skills = '', $wechat = '')
    {
        $model = new self();
        $model->user_id = $userId;
        $model->skills = $skills;
        $model->wechat = $wechat;
        $model->status = self::STATUS_OK;
        return $model->saveOrFail() ? 1 : 0;
    }

    /**
     * 申请记录
     */
    static function checkRecord($userId = 0)
    {
        return self::where('user_id', $userId)->orderBy('id', 'desc')->first();
    }
}
